package com.tianqu.tms.www.attn.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.entity.Attn;
import com.tianqu.tms.entity.User;
import com.tianqu.tms.www.attn.viewhelper.AttnViewhelper;

/**
 * @author zhangxueliang
 * 经办人 登录信息查看
 */
public class AttnLoginDetailAction extends TmsAction{
	private static final String ATTNID = "attnId";
	private Logger logger = Logger.getLogger(AttnLoginDetailAction.class);
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		String attnId = "";
		if(request.getParameter(ATTNID) != null){
			attnId = request.getParameter(ATTNID);
		}else{
			attnId = (String)uc.getAttribute(ATTNID);
		}
		uc.setAttribute(ATTNID, attnId);
		
		Attn attn = Attn.getInstance();
		attn = attn.findAttnByAttnId(attnId);
		AttnViewhelper viewhelper = new AttnViewhelper();
		viewhelper.setUserId(attn.getUserId());
		
		User user = new User();
		
		user = user.getUserProfileByLoginid(attn.getUserId(), TmsConstants.BLANK);
		viewhelper.setPassword(user.getPassword());
		viewhelper.setAttnId(attnId);
		uc.setAttribute(TmsConstants.VIEWHELP, viewhelper);
		request.setAttribute(TmsConstants.VIEWHELP, viewhelper);
		logger.debug(this.getClass().getName() + "#execute was completed.");
		return mapping.findForward(TmsConstants.SUCCESS);
	}

}
